home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 118 / cd-rom 118.iso / aplic / open / openofficeorg2.cab / ooo2wordml_list.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2005-01-31  |  20.8 KB  |  367 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.    The Contents of this file are made available subject to the terms of
  4.    either of the following licenses
  5.  
  6.           - GNU Lesser General Public License Version 2.1
  7.           - Sun Industry Standards Source License Version 1.1
  8.  
  9.    Sun Microsystems Inc., October, 2000
  10.  
  11.    GNU Lesser General Public License Version 2.1
  12.    =============================================
  13.    Copyright 2000 by Sun Microsystems, Inc.
  14.    901 San Antonio Road, Palo Alto, CA 94303, USA
  15.  
  16.    This library is free software; you can redistribute it and/or
  17.    modify it under the terms of the GNU Lesser General Public
  18.    License version 2.1, as published by the Free Software Foundation.
  19.  
  20.    This library is distributed in the hope that it will be useful,
  21.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  22.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  23.    Lesser General Public License for more details.
  24.  
  25.    You should have received a copy of the GNU Lesser General Public
  26.    License along with this library; if not, write to the Free Software
  27.    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28.    MA  02111-1307  USA
  29.  
  30.  
  31.    Sun Industry Standards Source License Version 1.1
  32.    =================================================
  33.    The contents of this file are subject to the Sun Industry Standards
  34.    Source License Version 1.1 (the "License"); You may not use this file
  35.    except in compliance with the License. You may obtain a copy of the
  36.    License at http://www.openoffice.org/license.html.
  37.  
  38.    Software provided under this License is provided on an "AS IS" basis,
  39.    WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
  40.    WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  41.    MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  42.    See the License for the specific provisions governing your rights and
  43.    obligations concerning the Software.
  44.  
  45.    The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  46.  
  47.    Copyright ┬⌐ 2002 by Sun Microsystems, Inc.
  48.  
  49.    All Rights Reserved.
  50.  
  51.    Contributor(s): _______________________________________
  52.    
  53.  -->
  54. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg   dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
  55.     <xsl:template name="ListStyles">
  56.         <w:lists>
  57.             <xsl:if test="descendant::text:list-level-style-image">
  58.                 <xsl:call-template name="PicLists"/>
  59.             </xsl:if>
  60.             <xsl:apply-templates select="office:styles/text:outline-style | office:styles/text:list-style | office:automatic-styles/text:list-style" mode="style"/>
  61.             <xsl:for-each select="office:styles/text:outline-style | office:styles/text:list-style | office:automatic-styles/text:list-style">
  62.                 <w:list w:ilfo="{position()}">
  63.                     <w:ilst w:val="{position()-1}"/>
  64.                 </w:list>
  65.             </xsl:for-each>
  66.         </w:lists>
  67.     </xsl:template>
  68.     <xsl:template match="text:list-style | text:outline-style" mode="style">
  69.         <w:listDef w:listDefId="{position()-1}">
  70.             <xsl:if test="name(..)='office:styles' and name()!='text:outline-style'">
  71.                 <w:styleLink w:val="{@style:name}"/>
  72.             </xsl:if>
  73.             <xsl:for-each select="text:list-level-style-number | text:list-level-style-bullet | text:list-level-style-image | text:outline-level-style">
  74.                 <xsl:if test="@text:level < 10">
  75.                     <w:lvl w:ilvl="{ @text:level - 1 }">
  76.                         <xsl:if test="name()='text:outline-level-style'">
  77.                             <xsl:variable name="headinglevel">
  78.                                 <xsl:value-of select="@text:level"/>
  79.                             </xsl:variable>
  80.                             <xsl:if test="/office:document/office:body//text:h[@text:level=$headinglevel and @text:style-name]">
  81.                                 <xsl:element name="w:pStyle">
  82.                                     <xsl:attribute name="w:val"><xsl:value-of select="/office:document/office:body//text:h[@text:level=$headinglevel]/@text:style-name"/></xsl:attribute>
  83.                                 </xsl:element>
  84.                             </xsl:if>
  85.                         </xsl:if>
  86.                         <xsl:choose>
  87.                             <xsl:when test="@text:start-value">
  88.                                 <w:start w:val="{@text:start-value}"/>
  89.                             </xsl:when>
  90.                             <xsl:otherwise>
  91.                                 <w:start w:val="1"/>
  92.                             </xsl:otherwise>
  93.                         </xsl:choose>
  94.                         <xsl:choose>
  95.                             <xsl:when test="@text:bullet-char">
  96.                                 <w:nfc w:val="23"/>
  97.                             </xsl:when>
  98.                             <xsl:when test="@style:num-format">
  99.                                 <xsl:call-template name="convert_list_number">
  100.                                     <xsl:with-param name="number-format" select="@style:num-format"/>
  101.                                 </xsl:call-template>
  102.                             </xsl:when>
  103.                         </xsl:choose>
  104.                         <xsl:choose>
  105.                             <xsl:when test="name()='text:list-level-style-image'">
  106.                                 <w:lvlText w:val="."/>
  107.                                 <w:lvlPicBulletId>
  108.                                     <xsl:attribute name="w:val"><xsl:value-of select="count(preceding::text:list-level-style-image)"/></xsl:attribute>
  109.                                 </w:lvlPicBulletId>
  110.                             </xsl:when>
  111.                             <xsl:when test="@text:bullet-char">
  112.                                 <w:lvlText w:val="{@text:bullet-char}"/>
  113.                             </xsl:when>
  114.                             <xsl:when test="@text:display-levels and not(../@text:consecutive-numbering='true')">
  115.                                 <xsl:variable name="levelText">
  116.                                     <xsl:call-template name="displaylevel">
  117.                                         <xsl:with-param name="number" select="@text:display-levels"/>
  118.                                         <xsl:with-param name="textlevel" select="@text:level"/>
  119.                                     </xsl:call-template>
  120.                                 </xsl:variable>
  121.                                 <w:lvlText w:val="{concat(@style:num-prefix, substring-after($levelText, '.'), @style:num-suffix)}"/>
  122.                             </xsl:when>
  123.                             <xsl:otherwise>
  124.                                 <w:lvlText w:val="{concat(@style:num-prefix, '%', @text:level, @style:num-suffix)}"/>
  125.                             </xsl:otherwise>
  126.                         </xsl:choose>
  127.                         <xsl:choose>
  128.                             <xsl:when test="style:list-level-properties/@fo:text-align = 'end'">
  129.                                 <w:lvlJc w:val="right"/>
  130.                             </xsl:when>
  131.                             <xsl:when test="style:list-level-properties/@fo:text-align = 'center'">
  132.                                 <w:lvlJc w:val="center"/>
  133.                             </xsl:when>
  134.                             <xsl:otherwise>
  135.                                 <w:lvlJc w:val="left"/>
  136.                             </xsl:otherwise>
  137.                         </xsl:choose>
  138.                         <xsl:choose>
  139.                             <xsl:when test="style:list-level-properties/@text:space-before | style:list-level-properties/@text:min-label-width | style:list-level-properties/@text:min-label-distance">
  140.                                 <xsl:call-template name="list_position"/>
  141.                             </xsl:when>
  142.                             <xsl:otherwise>
  143.                                 <w:suff w:val="Nothing"/>
  144.                             </xsl:otherwise>
  145.                         </xsl:choose>
  146.                         <xsl:apply-templates select="key('text-style',@text:style-name)/style:text-properties" mode="character"/>
  147.                         <xsl:apply-templates select="style:text-properties" mode="character"/>
  148.                     </w:lvl>
  149.                 </xsl:if>
  150.             </xsl:for-each>
  151.         </w:listDef>
  152.     </xsl:template>
  153.     <xsl:template match="text:list-style" mode="count">
  154.         <xsl:value-of select="count(preceding::text:list-style | preceding::text:outline-style)+1"/>
  155.     </xsl:template>
  156.     <xsl:template match="text:unordered-list | text:ordered-list | text:list">
  157.         <xsl:apply-templates select="text:unordered-list | text:ordered-list | text:list-item | text:list-header | text:list"/>
  158.     </xsl:template>
  159.     <xsl:template match="text:list-item | text:list-header">
  160.         <xsl:apply-templates select="text:unordered-list | text:ordered-list | text:list |  text:p |  text:h"/>
  161.     </xsl:template>
  162.     <xsl:template name="displaylevel">
  163.         <xsl:param name="number"/>
  164.         <xsl:param name="textlevel"/>
  165.         <xsl:if test="$number > 1">
  166.             <xsl:call-template name="displaylevel">
  167.                 <xsl:with-param name="number" select="$number -1"/>
  168.                 <xsl:with-param name="textlevel" select="number($textlevel)-1"/>
  169.             </xsl:call-template>
  170.         </xsl:if>
  171.         <xsl:value-of select="concat('.','%',$textlevel)"/>
  172.     </xsl:template>
  173.     <xsl:template name="list_position">
  174.         <xsl:variable name="spacebefore">
  175.             <xsl:choose>
  176.                 <xsl:when test="style:list-level-properties/@text:space-before">
  177.                     <xsl:call-template name="convert2twip">
  178.                         <xsl:with-param name="value" select="style:list-level-properties/@text:space-before"/>
  179.                     </xsl:call-template>
  180.                 </xsl:when>
  181.                 <xsl:otherwise>0</xsl:otherwise>
  182.             </xsl:choose>
  183.         </xsl:variable>
  184.         <xsl:variable name="space2text">
  185.             <xsl:choose>
  186.                 <xsl:when test="style:list-level-properties/@text:min-label-width">
  187.                     <xsl:call-template name="convert2twip">
  188.                         <xsl:with-param name="value" select="style:list-level-properties/@text:min-label-width"/>
  189.                     </xsl:call-template>
  190.                 </xsl:when>
  191.                 <xsl:otherwise>0</xsl:otherwise>
  192.             </xsl:choose>
  193.         </xsl:variable>
  194.         <xsl:variable name="spacedistance">
  195.             <xsl:choose>
  196.                 <xsl:when test="style:list-level-properties/@text:min-label-distance">
  197.                     <xsl:call-template name="convert2twip">
  198.                         <xsl:with-param name="value" select="style:list-level-properties/@text:min-label-distance"/>
  199.                     </xsl:call-template>
  200.                 </xsl:when>
  201.                 <xsl:otherwise>0</xsl:otherwise>
  202.             </xsl:choose>
  203.         </xsl:variable>
  204.         <xsl:if test="$spacedistance='0' and $space2text='0'">
  205.             <w:suff w:val="Nothing"/>
  206.         </xsl:if>
  207.         <w:pPr>
  208.             <xsl:if test="$spacedistance!='0' or $space2text!='0'">
  209.                 <w:tabs>
  210.                     <w:tab>
  211.                         <xsl:attribute name="w:val">list</xsl:attribute>
  212.                         <xsl:attribute name="w:pos"><xsl:choose><xsl:when test="number($spacedistance) > number($space2text)"><xsl:value-of select="number($spacebefore)+number($spacedistance)+150"/></xsl:when><xsl:otherwise><xsl:value-of select="number($spacebefore)+number($space2text)+150"/></xsl:otherwise></xsl:choose></xsl:attribute>
  213.                         <!-- Since SO MinSpaceDistance is width after number or bullet, MS TabSpaceAfter include the number or bullet width. So +150 -->
  214.                     </w:tab>
  215.                 </w:tabs>
  216.             </xsl:if>
  217.             <w:ind w:left="{number($space2text)+number($spacebefore)}" w:hanging="{$space2text}"/>
  218.             <!-- w:pos(MS TabSpaceAfter) = text:space-before + MAX(text:min-label-distance,text:min-label-width) + ( Symbol width ); w:left(MS IndentAt)= text:space-before + text:min-label-width; w:hanging(MS IndentAt - MS AlignedAt)=text:min-label-width -->
  219.         </w:pPr>
  220.     </xsl:template>
  221.     <xsl:template name="PicLists">
  222.         <xsl:for-each select="descendant::text:list-level-style-image">
  223.             <w:listPicBullet w:listPicBulletId="{position()-1}">
  224.                 <w:pict>
  225.                     <v:shape>
  226.                         <xsl:variable name="Picwidth">
  227.                             <xsl:call-template name="convert2pt">
  228.                                 <xsl:with-param name="value" select="style:list-level-properties/@fo:width"/>
  229.                             </xsl:call-template>
  230.                         </xsl:variable>
  231.                         <xsl:variable name="Picheight">
  232.                             <xsl:call-template name="convert2pt">
  233.                                 <xsl:with-param name="value" select="style:list-level-properties/@fo:height"/>
  234.                             </xsl:call-template>
  235.                         </xsl:variable>
  236.                         <xsl:attribute name="style"><xsl:value-of select="concat('width:', number($Picwidth*1), 'pt;height:', number($Picheight*1), 'pt')"/></xsl:attribute>
  237.                         <xsl:attribute name="o:bullet">t</xsl:attribute>
  238.                         <v:stroke joinstyle="miter"/>
  239.                         <w:binData w:name="{concat('wordml://SOpicbullet', position(), '.gif')}">
  240.                             <xsl:value-of select="office:binary-data"/>
  241.                         </w:binData>
  242.                         <v:imagedata src="{concat('wordml://SOpicbullet', position(), '.gif')}" o:title="{concat('SOpicbullet', position())}"/>
  243.                     </v:shape>
  244.                 </w:pict>
  245.             </w:listPicBullet>
  246.         </xsl:for-each>
  247.     </xsl:template>
  248.     <xsl:template name="convert_list_number">
  249.         <xsl:param name="number-format"/>
  250.         <xsl:choose>
  251.             <xsl:when test="$number-format = 'a'">
  252.                 <!-- nfcLCLetter: Lowercase alpah -->
  253.                 <w:nfc w:val="4"/>
  254.             </xsl:when>
  255.             <xsl:when test="$number-format = 'A'">
  256.                 <!-- nfcUCLetter: Uppercase alpha -->
  257.                 <w:nfc w:val="3"/>
  258.             </xsl:when>
  259.             <xsl:when test="$number-format = 'i'">
  260.                 <!-- nfcLCRoman: Lowercase roman -->
  261.                 <w:nfc w:val="2"/>
  262.             </xsl:when>
  263.             <xsl:when test="$number-format = 'I'">
  264.                 <!-- nfcUCRoman: Uppercase roman -->
  265.                 <w:nfc w:val="1"/>
  266.             </xsl:when>
  267.             <xsl:when test="$number-format = '∩╝æ, ∩╝Æ, ∩╝ô, ...'">
  268.                 <!-- '∩╝æ, ∩╝Æ, ∩╝ô, ...' also seems: decimal-full-width2 -->
  269.                 <w:nfc w:val="14"/>
  270.             </xsl:when>
  271.             <xsl:when test="$number-format = 'Γæá, Γæí, Γæó, ...'">
  272.                 <w:nfc w:val="18"/>
  273.             </xsl:when>
  274.             <xsl:when test="$number-format = 'Σ╕Ç, Σ║î, Σ╕ë, ...'">
  275.                 <!-- 'Σ╕Ç, Σ║î, Σ╕ë, ...' also seems: ideograph-digital, japanese-counting, japanese-digital-ten-thousand,
  276.                 taiwanese-counting, taiwanese-counting-thousand, taiwanese-digital, chinese-counting, korean-digital2 -->
  277.                 <w:nfc w:val="10"/>
  278.             </xsl:when>
  279.             <xsl:when test="$number-format = 'σú╣, Φ┤░, σÅü, ...'">
  280.                 <w:nfc w:val="38"/>
  281.             </xsl:when>
  282.             <xsl:when test="$number-format = 'σú╣, Φ▓│, σÅâ, ...'">
  283.                 <w:nfc w:val="34"/>
  284.             </xsl:when>
  285.             <xsl:when test="$number-format = 'τö▓, Σ╣Ö, Σ╕Ö, ...'">
  286.                 <w:nfc w:val="30"/>
  287.             </xsl:when>
  288.             <xsl:when test="$number-format = 'σ¡É, Σ╕æ, σ»à, ...'">
  289.                 <w:nfc w:val="31"/>
  290.             </xsl:when>
  291.             <xsl:when test="$number-format = 'σú▒, σ╝É, σÅé, ...'">
  292.                 <w:nfc w:val="16"/>
  293.             </xsl:when>
  294.             <xsl:when test="$number-format = 'πéó, πéñ, πéª, ...'">
  295.                 <w:nfc w:val="12"/>
  296.             </xsl:when>
  297.             <xsl:when test="$number-format = '∩╜▒, ∩╜▓, ∩╜│, ...'">
  298.                 <w:nfc w:val="20"/>
  299.             </xsl:when>
  300.             <xsl:when test="$number-format = 'πéñ, πâ¡, πâÅ, ...'">
  301.                 <w:nfc w:val="13"/>
  302.             </xsl:when>
  303.             <xsl:when test="$number-format = '∩╜▓, ∩╛¢, ∩╛è, ...'">
  304.                 <w:nfc w:val="21"/>
  305.             </xsl:when>
  306.             <xsl:when test="$number-format = '∞¥╝, ∞¥┤, ∞é╝, ...'">
  307.                 <!-- '∞¥╝, ∞¥┤, ∞é╝, ...' also seems: korean-counting -->
  308.                 <w:nfc w:val="41"/>
  309.             </xsl:when>
  310.             <xsl:when test="$number-format = 'πä▒, πä┤, πä╖, ...' or $number-format = 'πëá, πëí, πëó, ...'">
  311.                 <!-- mapping circled to uncirled -->
  312.                 <w:nfc w:val="25"/>
  313.             </xsl:when>
  314.             <xsl:when test='$number-format = "Ω░Ç, δéÿ, δïñ, ..." or $number-format = "πë«, πë», πë░, ..."'>
  315.                 <!-- mapping circled to uncirled -->
  316.                 <w:nfc w:val="24"/>
  317.             </xsl:when>
  318.             <xsl:when test="$number-format ='╪ú, ╪¿, ╪¬, ...'">
  319.                 <!-- 46.    hebrew-1-->
  320.                 <w:nfc w:val="46"/>
  321.             </xsl:when>
  322.             <xsl:when test="$number-format = 'α╕ü, α╕é, α╕â, ...'">
  323.                 <!--53.    thai-letters not match well !-->
  324.                 <w:nfc w:val="53"/>
  325.             </xsl:when>
  326.             <xsl:when test="$number-format='╫É, ╫æ, ╫Æ, ...'">
  327.                 <!--45.    arabic-alpha-->
  328.                 <w:nfc w:val="45"/>
  329.             </xsl:when>
  330.             <xsl:when test="string-length($number-format)=0">
  331.                 <w:nfc w:val="255"/>
  332.             </xsl:when>
  333.             <xsl:when test="$number-format = 'Native Numbering'">
  334.                 <xsl:variable name="locale" select="/office:document/office:meta/dc:language"/>
  335.                 <xsl:choose>
  336.                     <xsl:when test="starts-with($locale, 'th-')">
  337.                         <!-- for Thai, mapping thai-numbers, thai-counting to thai-numbers -->
  338.                         <w:nfc w:val="54"/>
  339.                     </xsl:when>
  340.                     <xsl:when test="starts-with($locale, 'hi-')">
  341.                         <!-- for Hindi, mapping hindi-vowels, hindi-consonants, hindi-counting to hindi-numbers -->
  342.                         <w:nfc w:val="51"/>
  343.                     </xsl:when>
  344.                     <xsl:when test="starts-with($locale, 'ar-')">
  345.                         <!-- for Arabic, mapping  arabic-abjad to arabic-alpha -->
  346.                         <w:nfc w:val="45"/>
  347.                     </xsl:when>
  348.                     <xsl:when test="starts-with($locale, 'he-')">
  349.                         <!-- for Hebrew, mapping hebrew-2 to  -->
  350.                         <w:nfc w:val="46"/>
  351.                     </xsl:when>
  352.                     <xsl:when test="starts-with($locale, 'ru-')">
  353.                         <!-- for Russian, mapping russian-upper to russian-lower -->
  354.                         <w:nfc w:val="58"/>
  355.                     </xsl:when>
  356.                     <xsl:when test="starts-with($locale, 'vi-')">
  357.                         <!-- for Vietnamese -->
  358.                         <w:nfc w:val="56"/>
  359.                     </xsl:when>
  360.                 </xsl:choose>
  361.             </xsl:when>
  362.             <!-- unsupported: ordinal, cardinal-text, ordinal-text, hex, chicago, bullet, ideograph-zodiac-traditional, 
  363.             chinese-not-impl, korean-legal, none  -->
  364.         </xsl:choose>
  365.     </xsl:template>
  366. </xsl:stylesheet>
  367.